<link href="/css/order/prodetail.css" rel="stylesheet" type="text/css"/>
<script language="javascript">
    function refresh() {
        var height = $('#details_panel').height();
        window.parent.$('#ifr_order_product_detail').height(height + 5);
    }
    function uClose() {
        window.parent.$('#ifr_order_product_detail').dialog('close');
    }

    function saveUpdate() {
        if ($("#comment").val() == '') {
            alertTip('<{$lang.remark}><{$lang.can_not_be_empty}>！');
            return;
        }
        var url = '/order/order/updateproduct';
        $.post(url, $('#op_form').serializeArray(), function(data) {
            if (data == null)return;
            else if (data.ask == 1) {
                window.parent.isReload = true;
                uClose();
            } else {
                alertTip(data.msg);
            }
        }, 'json');
    }
    //存货情况
    function loadlist(pid) {
        $.ajax({
            type: "post",
            async: false,
            dataType: "json",
            url: "/warehouse/products/getinventory",
            data: "product_id=" + pid,
            success: function(json) {
                var list = "";
                if (json == null)return;
                if (json.ask == 1) {
                    var hold = json.result.wp_quantity_hold != 0 ? json.result.wp_quantity_hold : '<{$lang.no}>';
                    list += "<tr>";
                    list += "<td class=\"wColumn1\">" + json.result.warehouse_id + "</td>";
                    list += "<td class=\"wColumn2\">" + json.result.wp_quantity + "</td>";
                    list += "<td class=\"wColumn4\">" + hold + "</td>";
                    list += "<td class=\"wColumn3\">" + json.result.ws_code + "</td>";
                    list += "</tr>";
                    $("#loadlist").html(list);
                }
            }
        });
    }
    //<{$lang.operation}><{$lang.tip}>
    function alertTip(tip) {
        $('<div title="<{$lang.tip}>"><p align="center">' + tip + '</p></div>').dialog({
            modal: true,
            buttons: {
                '<{$lang.ok}>': function() {
                    $(this).dialog("close");
                }
            }
        });
    }
    $(function() {
        var pid = $("#product_id").val();
        loadlist(pid);//<{$lang.inventory}><{$lang.quantity}>
    })
</script>

<style>
    .wColumn1 {
        width: 25%;
        text-align: center;
    }

    .wColumn2 {
        width: 25%;
        text-align: center;
    }

    .wColumn3 {
        width: 25%;
        text-align: center;
    }

    .wColumn4 {
        width: 25%;
        text-align: center;
    }
</style>
<div id="auth_tips" style="display: none;" title="<{$lang.msg}><{$lang.tip}>">
    <div style="height: 64px;line-height: 50px;">
        <p style="text-align:center;font-size: 14px;color: red;font-weight: bold;" id="auth_tips_content"></p>
    </div>
</div>
<div id="details_panel" style="border:1px solid #5B7EA0;">
    <form name="op_form" id="op_form">
        <input type="hidden" name="op_id" id="op_id" value="<{$op_id}>">
        <input type="hidden" name="orders_code" id="orders_code" value="<{$orders_code}>">
        <input type="hidden" name="product_id" id="product_id" value="<{$product_id}>"/>

        <div id="single-page-tbar">
            <h1>
                <strong><{$lang.orders_code}>:</strong><{$orders_code}>
            </h1>
            <ul class="btn-bar">

                <li id="btn_quit">
                    <span class="btn btn-save" onclick="if(confirm('<{$lang.ok}><{$lang.close}><{$lang.window}>?')){uClose();}"> <span><span>Close/<{$lang.close}></span></span> </span>
                </li>
                <li id="btn_quit">
				<span class="btn btn-save " onclick="saveUpdate()">
<span>
<span>Save/<{$lang.save}></span>
</span>
</span>
                </li>
            </ul>
        </div>
        <div id="tips" class="validateTips">
        </div>
        <div class="bill">
            <table cellpadding="2" cellspacing="0">
                <tbody class="bill-content">
                <tr>
                    <td class="bill-item-left"><{$lang.order}><{$lang.product}><{$lang.name}>:</td>
                    <td class="bill-item-right">
                        <input type="text" name="pd_name" id="pd_name" value="<{$op_title}>" style="width:90%;"/>
                    </td>
                </tr>
                <tr>
                    <td class="bill-item-left"><{$lang.product}>ID:</td>
                    <td class="bill-item-right">
                        <{$product_id}>
                    </td>
                </tr>
                <tr>
                    <td class="bill-item-left"><{$lang.declar_price}>:</td>
                    <td class="bill-item-right">
                        <{$op_declared_value}>
                    </td>
                </tr>
                <tr>
                    <td class="bill-item-left"><{$lang.quantity}>:</td>
                    <td class="bill-item-right">
                        <input type="text" name="product_quantity" id="product_quantity" value="<{$op_quantity}>"/>
                    </td>
                </tr>
                <tr>
                    <td class="bill-item-left"><{$lang.sku}>:</td>
                    <td class="bill-item-right">
                        <{$product_sku}>
                    </td>
                </tr>
                <tr>
                    <td class="bill-item-left"><{$lang.remark}><span style="color: red;">(*)</span>:</td>
                    <td class="bill-item-right">
                        <textarea id="comment" name="comment" style="width: 90%;" rows="2"></textarea>
                    </td>
                </tr>

                </tbody>
            </table>
        </div>
    </form>
    <div>
        <div id="iContent">
            <table cellpadding="2" cellspacing="0">
                <tbody class="header-tips">
                <tr>
                    <td colspan="5"><{$lang.warehouse}><{$lang.detail}></td>
                </tr>
                </tbody>
                <tbody>
                <tr class="iHead">
                    <td class="wColumn1"><{$lang.warehouse}>ID</td>
                    <td class="wColumn2"><{$lang.quantity}></td>
                    <td class="wColumn4"><{$lang.hold}><{$lang.inventory}></td>
                    <td class="wColumn3"><{$lang.ws_code}></td>
                </tr>
                </tbody>
                <tbody id="loadlist">
                <tr>
                    <td class="wColumn1" colspan="4" align="center"><{$lang.warehouse}><{$lang.not_exists}><{$lang.product}></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>

</div>
<script language="javascript">
    refresh();
</script>